Pearson Edexcel · GCSE · Computer Science

    Course version: 1CP2 · Version from Sept 2020

    Be able to write programs that use logical operators (AND, OR, NOT)

    Full specification wording

    Operators: 6.5.3 be able to write programs that use logical operators (AND, OR, NOT)

    This criterion requires you to write working program code, not merely to describe operators.

    Checked against the Pearson Edexcel 1CP2 specification (opens in a new tab) on .

    • Point 3 of 3
    • 3 key terms

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    This criterion requires you to write working program code, not merely to describe operators. In a language such as Python, AND, OR and NOT combine or invert Boolean expressions so a single condition can test several facts. AND is true only when both operands are true; OR is true when at least one operand is true; NOT reverses a Boolean value. For example, a program might admit a pupil when age >= 11 AND age <= 16, warn when score < 40 OR attendance < 80, and print a message only when NOT submitted. You must choose the correct operator for the intended logic, place it between valid Boolean expressions, and test the program with inputs that make each combined condition true and false. Assessment asks you to select or write code whose logic matches a stated rule, so trace each operand before deciding.

    What earns the marks

    • AND returns true only when both operands are true, so a rule requiring two conditions to hold together must use AND.
    • OR returns true when at least one operand is true, so a rule allowing either condition to qualify must use OR.
    • NOT inverts a single Boolean value or expression, turning true into false and false into true.
    • Each operand of AND or OR must itself be a Boolean expression, such as a comparison, not a bare value.
    • Correct code applies the operator to the intended conditions and produces the outcome stated in the question for every tested input.

    Common mistakes and how to put them right

    • Using AND when the rule means either condition is enough.

      Put it right by using OR so one true operand makes the whole condition true.

    • Using OR when both conditions must hold.

      Put it right by using AND so the result is true only when both operands are true.

    • Placing NOT before a comparison without checking the resulting logic.

      Put it right by tracing the inverted value and confirming it matches the intended rule.

    Exam tips

    • Rewrite the stated rule in words as 'both', 'either' or 'not' before choosing the operator.
    • Trace one input that should pass and one that should fail through the full condition to confirm the operator.
    • Check that each side of AND or OR is a complete comparison rather than a single value.

    Try the lesson

    The start of the Operators: 6.5.3 be able to write programs that use logical operators (AND, OR, NOT) lesson, made from checked teaching notes for this specification point.

    Have a go first

    A program sets score to 7. What is the result of the expression (score > 5) AND (score < 10)?

    Listen

    This criterion requires you to write working program code, not merely to describe operators. In a language such as Python, AND, OR and NOT combine or invert Boolean expressions so a single condition can test several facts. AND is true only when both operands are true; OR is true when at least one operand is true; NOT reverses a Boolean value. For example, a program might admit a pupil when age >= 11 AND age <= 16, warn when score < 40 OR attendance < 80, and print a message only when NOT submitted. You must choose the correct operator for the intended logic, place it between valid Boolean expressions, and test the program with inputs that make each combined condition true and false. Assessment asks you to select or write code whose logic matches a stated rule, so trace each operand before deciding. A strong answer earns marks for these points. AND returns true only when both operands are true, so a rule requiring two conditions to hold together must use AND. OR returns true when at least one operand is true, so a rule allowing either condition to qualify must use OR. NOT inverts a single Boolean value or expression, turning true into false and false into true. Each operand of AND or OR must itself be a Boolean expression, such as a comparison, not a bare value. A common slip: Using AND when the rule means either condition is enough. Instead, using OR so one true operand makes the whole condition true. Exam tip: Rewrite the stated rule in words as 'both', 'either' or 'not' before choosing the operator.

    See it

    A top-down flowchart. The top node 'Logical operators' branches into three nodes: 'AND', 'OR' and 'NOT'. 'AND' leads to 'True only when both operands are true'. 'OR' leads to 'True when at least one operand is true'. 'NOT' leads to 'Reverses a Boolean value'.
    It classifies the three logical operators AND, OR and NOT and states the result each one gives.

    Key words

    Say what each word means before you turn the card.

    Combining conditions

    Try answering aloud or in your head before turning the card.

    Operator selection

    Try answering aloud or in your head before turning the card.

    Program testing

    Try answering aloud or in your head before turning the card.

    See every definition
    Combining conditions
    Using AND, OR and NOT to join or invert Boolean expressions so one condition tests several facts.
    Operator selection
    Choosing the correct operator for the intended logic and placing it between valid Boolean expressions.
    Program testing
    Testing the program with inputs that make each combined condition true and false.

    Label the diagram

    Some boxes have lost their names. Pick the right name for each number.

    The diagram again, with 3 boxes numbered instead of named. A top-down flowchart. The top node 'Logical operators' branches into three nodes: 'AND', 'OR' and 'NOT'. 'AND' leads to 'True only when both operands are true'. 'OR' leads to 'True when at least one operand is true'. 'NOT' leads to 'Reverses a Boolean value'.
    • 1Box 1

    • 2Box 2

    • 3Box 3

    0 of 3 labelled

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Operators: 6.5.3 be able to write programs that use logical operators (AND, OR, NOT)

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge